<?php
/* phpYahooMyWeb Class 1.0.0
 * Written by Jay Denis (jay@gotfoo.org)
 * Google Project Page: http://code.google.com/p/phpyahoo/
 * Released under GNU Lesser General Public License (http://www.gnu.org/copyleft/lgpl.html)
 * For more information about the class and upcoming tools and toys using it,
 * visit hhttp://phpYahoo.gotfoo.org or http://code.google.com/p/phpyahoo/
 *
 *
 *     Please submit all issues to the project page:
 *         http://code.google.com/p/phpyahoo/issues/list
 * 
 
 */
class phpYahooMyWeb extends phpYahoo{
	
	
	var $base_url_myweb = 'http://search.yahooapis.com/MyWebService/V1/';
	var $command_tag_search = 'tagSearch';
	var $command_related_tags = 'relatedTags';
	var $command_url_search = 'urlSearch';
	
	
    
    function request_tag_search ($command,$params) {   
	    
	    $xml = $this->request($this->base_url_myweb.$command,$params);		       
		$results = array();
		$i = 0;
		foreach($xml->Result as $result){			
			$results[$i] = array("tag"=>$result->Tag,"frequency"=>$result->Frequency ,"date"=>$this->formatDate($result->Date));
			$i++;				
		}
		//print_r($results);
		return $results;
    }
    
     function request_url_search ($params) {   
	    
	    $xml = $this->request($this->base_url_myweb.$this->command_url_search,$params);		       
		$results = array();
		$i = 0;
		foreach($xml->Result as $result){			
			$results[$i] = array("title"=>$result->Title,"summary"=>$result->Summary,"url"=>$result->Url,"clickUrl"=>$result->ClickUrl,"user"=>$result->User,"date"=>$this->formatDate($result->Date),"note"=>$result->Note);
			$i++;				
		}
		//print_r($results);
		return $results;
    }
    
    /*searchTags accepts either 
     an empty string which will return the top tags ex: searchTags();
     or an array of paramaters *note* the array can be any combo of paramaters  
     	exmple:
		$params = array("url"=>'http://gotfoo.org',"yahooid"=>'gotfoo_org',"sort"=>'tag',"results"=>'50');
		or
		$params = array("url"=>'http://gotfoo.org',"sort"=>'popularity',"start"=>'100');
		or
		$params = array("yahooid"=>'gotfoo_org',"sort"=>'date',"results"=>'50');
		
		searchTags($params);
     or a name/value pair url string
     	searchTags('url=http://you.gotfoo.org');
     */
    function searchTags($params=''){
				
   		$response =  $this->request_tag_search($this->command_tag_search,$params);
       	return $response;
    }
    
    /* relatedTags and searchUrls accept either 
     an empty string which will return the top tags ex: searchTags();
     or an array of paramaters *note* the array can be any combo of paramaters  
     	exmple:
		$params = array("tag"=>'php',"yahooid"=>'gotfoo_org',"sort"=>'tag',"results"=>'50');
		or
		$params = array("tag"=>'xml',"sort"=>'popularity',"start"=>'100');
		or
		$params = array("yahooid"=>'gotfoo_org',"sort"=>'date',"results"=>'50');
		
		searchTags($params);
     or a name/value pair url string
     	searchTags('tag=ajax');
     */
    function relatedTags($params){
			
		
   		$response =  $this->request_tag_search($this->command_related_tags,$params);
       	return $response;
    }
    
    function searchUrls($params){
			
		
   		$response =  $this->request_url_search($params);
       	return $response;
    }
    
    
    
    
   
}

?>